package com.zp.reflection;

import java.lang.reflect.Field;

public class ReflectTest6 {
	public static void main(String[] args) throws Exception {
		Private2 p = new Private2();
		Class<?> classType = p.getClass();
		Field field = classType.getDeclaredField("name");
		
		//访问私有方法使用：压制java的访问控制检查；
		field.setAccessible(true);
		
		System.out.println(p.getName());
		field.set(p,"zhangpeng");
		System.out.println(p.getName());
	}
}
